<?php namespace  Home\Controller;
use Hdphp\Controller\Controller;
//商品详情控制器
class DetailsController extends CommonController{
	public function index(){
		
		//得到哪一个商品的详情
		$gid = Q('get.gid',0,'intval');
		//sp($gid);exit;
		$goodsData = Db::table('goods')->join('goods_details','gid','=','goods_gid')->where("gid={$gid}")->get();
		//sp($goodsData);die;
		//把字符串转为数组
		$img = explode(',', $goodsData[0]['img']);
		//sp($img);die;
		$goodsData[0]['img'] = $img;
		//sp($goodsData);exit;
		View::with('goodsData',$goodsData);
		
//		sp($_SESSION);
		//购物车商品数
		$cartNum = count(isset($_SESSION['cart']['goods']) ? $_SESSION['cart']['goods'] : 0);
		
		View::with('cartNum',$cartNum);
	    View::make();
	}
}

 ?>